﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 抽奖小程序
{
    public partial class Form2 : Form
    {
        int i;
        int []flag=new int[105];
        private string pathname = string.Empty;
        System.DateTime TimeNow = new DateTime();
        System.DateTime playTimeNow = new DateTime();
        public Form2()
        {
            InitializeComponent();
            label1.Visible = false;
            textBox1.Visible = false;
            button4.Visible = false;
            for (int j = 0; j < 105; j++)
            {
                flag[j] = 0;
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            timer1.Start();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            Random ra = new Random();
            i = ra.Next(1, 98);
            if (flag[i] == 1)
            {
                i = ra.Next(1, 98);
            }
            // string temppath = Application.StartupPath+"\\Resources\\1.jpg";
            Bitmap b = new Bitmap(Application.StartupPath + @"\Resources\" + i + ".jpg");
            flag[i] = 1;//去重复操作
            pictureBox1.Image = b;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            timer1.Stop();
            Bitmap b = new Bitmap(Application.StartupPath + @"\Resources\" + 0 + ".jpg");
            pictureBox1.Image = b;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            label1.Visible = true;
            textBox1.Visible = true;
            button4.Visible = true;
            Bitmap b = new Bitmap(Application.StartupPath + @"\Resources\" + i + ".jpg");
            pictureBox1.Image = b;
        }

        private void button4_Click(object sender, EventArgs e)
        {

            label1.Visible = false;
            textBox1.Visible = false;
            button4.Visible = false;
            string temp=textBox1.Text;
            string[] rewordpeople = temp.Split(',');
            for (int j = 0; j < rewordpeople.Length; j++)
            {
                for (int k = 0; k < 41; k++)
                {
                    if (rewordpeople[j] == form1.nowstudent[k].name)
                    {
                        form1.nowstudent[k].money += 2;
                    }
                }
            }
        }
    }
}
